home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news!enno
- From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
- Newsgroups: comp.lang.c++
- Subject: Re: Q. only for ostrstream experts!!!
- Date: 07 Feb 1996 19:50:43 GMT
- Organization: Fachbereich Informatik, TH Darmstadt
- Distribution: world
- Message-ID: <ENNO.96Feb7205043@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- References: <4fab9d$1rp@fsuj01.rz.uni-jena.de>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- In-reply-to: mkt@isun04.inf.uni-jena.de's message of 7 Feb 1996 14:00:13 GMT
-
- In article <4fab9d$1rp@fsuj01.rz.uni-jena.de> mkt@isun04.inf.uni-jena.de (Tilo Koerbs) writes:
-
- Consider:
- ostrstream buf(); // dynamic buffer
- buf << "something" << ends;
- char *p = buf.str(); // freeze buffer and return a pointer to it
-
- Now: How do I delete the pointer p, using 'delete' or using 'delete[]'?
-
- Please: Post only an answer if you are really sure! And consider: Even different
- books give different answers!
-
- So if you know a standard's paper or the description of the original
- implementation or something else, please post!
-
- None of the proposed solutions is a reasonable way to release the allocated
- memory. An ostrstream provides the member-function 'freeze' which should be
- used to mark the underlying buffer as 'destroyable'.
- Anyway according to the DWP the memory for this buffer is _usually_ allocated
- via 'new char[...]' in which case 'delete[]' would be the right choice.
-
- Enno
-